<template>
	<div>
		<uni-indexed-list :options="list" :showSelect="false" @click="bindClick"></uni-indexed-list>
	</div>
</template>

<script>
import { selectUser, selectDept } from '@/api/user.js'
	export default {
		data() {
			return {
				list:[{
					"letter": "北京",
					"data": [
						"阿克苏机场",
						"阿拉山口机场",
						"阿勒泰机场",
						"阿里昆莎机场",
						"安庆天柱山机场",
						"澳门国际机场"
					]
				}, {
					"letter": "广州",
					"data": [
						"保山机场",
						"包头机场",
						"北海福成机场",
						"北京南苑机场",
						"北京首都国际机场"
					]
				}],
				more: 'noMore',
				loaded: 0,
				param:{
					pageNum: 0,
					pageSize: 10,
					orderByColumn: 'id',
					isAsc: 'DESC'
				},
				info:{
					content:'',
				}
			}
		},
		onLoad() {
			this.getList();
		},
		methods:{
			getList() {
				selectDept().then(response => {
					let deptList = [];
					for(var i=0;i<response.rows.length;i++){
						deptList.push({data:[],letter:response.rows[i]['deptName']});
					}
					selectUser().then(res => {
						for(var j=0;j<res.rows.length;j++){
							for(var k=0;k<deptList.length;k++){
								if(deptList[k]['letter'] == res.rows[j]['dept']['deptName']){
									deptList[k]['data'].push(res.rows[j]['nickName']);
								}
							}
						}
						this.list = deptList;
					})
				});

			},
			viewMsg(msg) {
				this.info.content = msg.content;
				this.$refs.popup.open()
				if(msg.readTime == null){
					readMsg(msg.id);
					msg.readTime = '';
				}
			},
			dialogConfirm(done) {
				this.$refs.popup.open();
				done();
			}
		}
	}
</script>

<style>
</style>
